package com.example.city_defense;

import java.util.ArrayList;
public class World {

	int map;
	int level;
	public int[][] tileMap;
	public int[][] startPosition;
	public ArrayList<Attack> scenario;

	public World(int map, int level) {
		this.map = map;
		this.level = level;
		this.loadMap();
	}

	public void loadMap() {
		// load start position
		// tileY , tileX , desY , desX , y ,x
		this.startPosition = new int[][] { { 0, 9, 100, 475, 25, 475 },
				{ 0, 9, 100, 475, -100, 470 }, { 0, 11, 100, 575, -50, 575 },
				{ 0, 11, 100, 575, -175, 575 }, { 0, 9, 100, 475, -225, 480 },
				{ 0, 11, 100, 575, -300, 575 }, { 0, 9, 100, 475, -350, 470 },
				{ 0, 11, 100, 575, -425, 575 }, { 0, 9, 100, 475, -475, 480 },
				{ 0, 11, 100, 575, -550, 575 }, };
		// load array tileMap
		if (map == 1) {
			// Map 1
			this.tileMap = new int[][] {
					{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 0, -1, -1, -1 },
					{ 1, 1, 1, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, -1, -1, -1 },
					{ 1, 1, 0, 3, 3, 3, 3, 3, 3, 3, 0, 0, -1, -1, -1, -1 },
					{ 1, 1, 0, 3, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
					{ 1, 1, 0, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
							-1 },
					{ 1, 0, 0, 3, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, -1, -1 },
					{ 1, 0, 0, 3, -1, -1, 0, 3, 3, 3, 3, 3, 3, 0, 0, -1 },
					{ 1, 0, 0, 3, 3, 3, 3, 3, 1, 1, 1, 1, 3, 0, 0, -1 },
					{ 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 3, 0, 0, -1 },
					{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 3, 0, -1, -1 },
					{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 3, 3, -1, -1, -1 },
					{ 1, 1, 1, 1, 1, 1, 1, 1, 0, 3, 3, 3, -1, -1, -1, -1 },
					{ 2, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, -1, -1, -1, -1, -1 },
					{ 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, -1, -1, -1, -1, -1, -1 },
					{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
							-1, -1 },
					{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
							-1, -1 } };

		}
		// map2
		else if (map == 2) {

		}
		// map 3
		else {

		}

		// load array scenario
		if (level == 1) {
			// Time = 90s
			Setting.time = 90;
			// Level easy . 30 Attacks
			this.scenario = new ArrayList<Attack>();
			/* 1 */scenario.add(new Attack(1, 1, 30, false, false));
			/* 2 */scenario.add(new Attack(2, 1, 30, false, false));
			/* 3 */scenario.add(new Attack(3, 1, 30, true, false));
			/* 4 */scenario.add(new Attack(4, 1, 30, true, true));
			/* 5 */scenario.add(new Attack(5, 10, 30, false, false));
			/* 6 */scenario.add(new Attack(6, 10, 30, true, true));
			/* 7 */scenario.add(new Attack(7, 10, 30, true, true));
			/* 8 */scenario.add(new Attack(8, 10, 30, true, true));
			/* 9 */scenario.add(new Attack(9, 10, 30, true, true));
			/* 10 */scenario.add(new Attack(10, 10, 30, true, true));
			/* 11 */scenario.add(new Attack(5, 4, 30, true, true));
			/* 12 */scenario.add(new Attack(1, 1, 30, false, false));
			/* 13 */scenario.add(new Attack(7, 3, 30, false, false));
			/* 14 */scenario.add(new Attack(8, 5, 30, true, false));
			/* 15 */scenario.add(new Attack(2, 2, 30, true, true));
			/* 16 */scenario.add(new Attack(3, 1, 30, false, false));
			/* 17 */scenario.add(new Attack(8, 2, 30, true, true));
			/* 18 */scenario.add(new Attack(1, 2, 30, true, true));
			/* 19 */scenario.add(new Attack(3, 6, 30, true, true));
			/* 20 */scenario.add(new Attack(4, 2, 30, true, true));
			/* 21 */scenario.add(new Attack(4, 3, 30, true, true));
			/* 22 */scenario.add(new Attack(5, 4, 30, true, true));
			/* 23 */scenario.add(new Attack(1, 1, 30, false, false));
			/* 24 */scenario.add(new Attack(3, 3, 30, false, false));
			/* 25 */scenario.add(new Attack(4, 5, 30, true, false));
			/* 26 */scenario.add(new Attack(2, 2, 30, true, true));
			/* 27 */scenario.add(new Attack(8, 1, 30, false, false));
			/* 28 */scenario.add(new Attack(9, 9, 30, true, true));
			/* 29 */scenario.add(new Attack(3, 2, 30, true, true));
			/* 30 */scenario.add(new Attack(4, 6, 30, true, true));
		} else if (level == 2) {
			// Time = 90s
			Setting.time = 60;
			// Level medium 40 Attacks
			this.scenario = new ArrayList<Attack>();
			/* 1 */scenario.add(new Attack(1, 1, 30, false, false));
			/* 2 */scenario.add(new Attack(2, 1, 30, false, false));
			/* 3 */scenario.add(new Attack(3, 10, 30, true, false));
			/* 4 */scenario.add(new Attack(4, 10, 30, true, true));
			/* 5 */scenario.add(new Attack(5, 10, 30, false, false));
			/* 6 */scenario.add(new Attack(6, 10, 30, true, true));
			/* 7 */scenario.add(new Attack(7, 10, 30, true, true));
			/* 8 */scenario.add(new Attack(8, 10, 30, true, true));
			/* 9 */scenario.add(new Attack(9, 10, 30, true, true));
			/* 10 */scenario.add(new Attack(10, 10, 30, true, true));
			/* 11 */scenario.add(new Attack(5, 4, 30, true, true));
			/* 12 */scenario.add(new Attack(1, 1, 30, false, false));
			/* 13 */scenario.add(new Attack(7, 3, 30, false, false));
			/* 14 */scenario.add(new Attack(8, 5, 30, true, false));
			/* 15 */scenario.add(new Attack(2, 2, 30, true, true));
			/* 16 */scenario.add(new Attack(3, 1, 30, false, false));
			/* 17 */scenario.add(new Attack(8, 2, 30, true, true));
			/* 18 */scenario.add(new Attack(1, 2, 30, true, true));
			/* 19 */scenario.add(new Attack(3, 6, 30, true, true));
			/* 20 */scenario.add(new Attack(4, 2, 30, true, true));
			/* 21 */scenario.add(new Attack(4, 3, 30, true, true));
			/* 22 */scenario.add(new Attack(5, 4, 30, true, true));
			/* 23 */scenario.add(new Attack(1, 1, 30, false, false));
			/* 24 */scenario.add(new Attack(3, 3, 30, false, false));
			/* 25 */scenario.add(new Attack(4, 5, 30, true, false));
			/* 26 */scenario.add(new Attack(2, 2, 30, true, true));
			/* 27 */scenario.add(new Attack(8, 1, 30, false, false));
			/* 28 */scenario.add(new Attack(9, 9, 30, true, true));
			/* 29 */scenario.add(new Attack(3, 2, 30, true, true));
			/* 30 */scenario.add(new Attack(4, 6, 30, true, true));
			/* 31 */scenario.add(new Attack(1, 2, 30, true, true));
			/* 32 */scenario.add(new Attack(10, 3, 30, true, true));
			/* 33 */scenario.add(new Attack(10, 4, 30, true, true));
			/* 34 */scenario.add(new Attack(8, 1, 30, false, false));
			/* 35 */scenario.add(new Attack(9, 9, 30, true, true));
			/* 36 */scenario.add(new Attack(3, 2, 30, true, true));
			/* 37 */scenario.add(new Attack(4, 6, 30, true, true));
			/* 38 */scenario.add(new Attack(1, 2, 30, true, true));
			/* 39 */scenario.add(new Attack(10, 3, 30, true, true));
			/* 40 */scenario.add(new Attack(10, 4, 30, true, true));
		} else {
			// Time = 90s
			Setting.time = 45;
			// LEvel hard 50 Attacks
			this.scenario = new ArrayList<Attack>();
			/* 1 */scenario.add(new Attack(1, 1, 30, false, false));
			/* 2 */scenario.add(new Attack(2, 1, 30, false, false));
			/* 3 */scenario.add(new Attack(3, 1, 30, true, false));
			/* 4 */scenario.add(new Attack(4, 10, 30, true, true));
			/* 5 */scenario.add(new Attack(5, 10, 30, false, false));
			/* 6 */scenario.add(new Attack(6, 10, 30, true, true));
			/* 7 */scenario.add(new Attack(7, 10, 30, true, true));
			/* 8 */scenario.add(new Attack(8, 10, 30, true, true));
			/* 9 */scenario.add(new Attack(9, 10, 30, true, true));
			/* 10 */scenario.add(new Attack(10, 10, 30, true, true));
			/* 11 */scenario.add(new Attack(5, 4, 30, true, true));
			/* 12 */scenario.add(new Attack(1, 1, 30, false, false));
			/* 13 */scenario.add(new Attack(7, 3, 30, false, false));
			/* 14 */scenario.add(new Attack(8, 5, 30, true, false));
			/* 15 */scenario.add(new Attack(2, 2, 30, true, true));
			/* 16 */scenario.add(new Attack(3, 1, 30, false, false));
			/* 17 */scenario.add(new Attack(8, 2, 30, true, true));
			/* 18 */scenario.add(new Attack(1, 2, 30, true, true));
			/* 19 */scenario.add(new Attack(3, 6, 30, true, true));
			/* 20 */scenario.add(new Attack(4, 2, 30, true, true));
			/* 21 */scenario.add(new Attack(4, 3, 30, true, true));
			/* 22 */scenario.add(new Attack(5, 4, 30, true, true));
			/* 23 */scenario.add(new Attack(1, 1, 30, false, false));
			/* 24 */scenario.add(new Attack(3, 3, 30, false, false));
			/* 25 */scenario.add(new Attack(4, 5, 30, true, false));
			/* 26 */scenario.add(new Attack(2, 2, 30, true, true));
			/* 27 */scenario.add(new Attack(8, 1, 30, false, false));
			/* 28 */scenario.add(new Attack(9, 9, 30, true, true));
			/* 29 */scenario.add(new Attack(3, 2, 30, true, true));
			/* 30 */scenario.add(new Attack(4, 6, 30, true, true));
			/* 31 */scenario.add(new Attack(1, 2, 30, true, true));
			/* 32 */scenario.add(new Attack(10, 3, 30, true, true));
			/* 33 */scenario.add(new Attack(10, 4, 30, true, true));
			/* 34 */scenario.add(new Attack(8, 5, 30, true, false));
			/* 35 */scenario.add(new Attack(2, 2, 30, true, true));
			/* 36 */scenario.add(new Attack(3, 1, 30, false, false));
			/* 37 */scenario.add(new Attack(8, 2, 30, true, true));
			/* 38 */scenario.add(new Attack(1, 2, 30, true, true));
			/* 39 */scenario.add(new Attack(3, 6, 30, true, true));
			/* 40 */scenario.add(new Attack(4, 2, 30, true, true));
			/* 41 */scenario.add(new Attack(4, 3, 30, true, true));
			/* 42 */scenario.add(new Attack(5, 4, 30, true, true));
			/* 43 */scenario.add(new Attack(1, 1, 30, false, false));
			/* 44 */scenario.add(new Attack(3, 3, 30, false, false));
			/* 45 */scenario.add(new Attack(4, 5, 30, true, false));
			/* 46 */scenario.add(new Attack(2, 2, 30, true, true));
			/* 47 */scenario.add(new Attack(8, 1, 30, false, false));
			/* 48 */scenario.add(new Attack(9, 9, 30, true, true));
			/* 49 */scenario.add(new Attack(3, 2, 30, true, true));
			/* 50 */scenario.add(new Attack(4, 6, 30, true, true));
		}
	}

	public boolean canBuildTower(int j, int i) {
		// TODO Auto-generated method stub
		if (tileMap[i][j] == 1 || tileMap[i][j] == -1) {
			return true;
		} else
			return false;
	}
}
